/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ASAInst;

import ASAExpr.ASAExpr;
import exception.DivisionByZeroException;
import exception.VariableNonDeclareeException;

/**
 *
 * @author FM & KB
 */
public class ASAInstExpr extends ASAInst {
    private ASAExpr expr;
    
    public ASAInstExpr(ASAExpr expr){
        this.expr = expr;
    }

    @Override
    public void executer() throws VariableNonDeclareeException, DivisionByZeroException {
        expr.evalue();
    }

    @Override
    public String notationExplorateur(String prefixe) {
        String res = prefixe + getLabelExplorateur() + "\n";
        String prefixeSuiv = prefixe + "   ";
        
        if (expr != null){
            res += expr.notationExplorateur(prefixeSuiv);
        }else{
            res += prefixeSuiv + "VIDE\n";
        }
        return res;
    }

    @Override
    public String getLabelExplorateur() {
        return "INST_EXPR";
    }
    
    public ASAInst simplifie() throws VariableNonDeclareeException, DivisionByZeroException{
          ASAExpr expr_simpl = expr.simplifie();
          return new ASAInstExpr(expr_simpl);
    }
}
